package com.douban.business;

import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLString;

import com.douban.business.vo.ItemVO;
import com.douban.business.vo.RecordingStatusVO;

public abstract class Recorder {

	protected QName element;
	protected XMLAttributes attrs;
	protected Augmentations augs;
	protected ItemVO itemvo;
	protected RecordingStatusVO rstatus;
	protected XMLString text;
	protected int recordingMode = 0;
	
	public static final int START_ELEMENT = 1;
	public static final int END_ELEMENT = START_ELEMENT*2;
	public static final int CHARACTERS_ELEMENT = END_ELEMENT*2;
	
	public Recorder(ItemVO itemvo, RecordingStatusVO rstatus, Object elementOrText, XMLAttributes attrs,
			Augmentations augs, int elementMode){
		this.itemvo=itemvo;
		if(elementOrText instanceof QName){
			this.element = (QName)elementOrText;
		}else if(elementOrText instanceof XMLString){
			this.text = (XMLString)elementOrText;
		}
		this.attrs = attrs;
		this.augs = augs;
		this.rstatus = rstatus;
		this.recordingMode = elementMode;
		recording();
	}	
	
	public int getRecordingMode() {
		return recordingMode;
	}



	public void setRecordingMode(int recordingMode) {
		this.recordingMode = recordingMode;
	}
	
	ItemVO getItemVO(){
		return itemvo;
	}
	
	/**
	 * parsing the element attributes and put the values into itemvo
	 */
	abstract protected void recording();
}
